@echo off
chcp 65001 >nul
echo ========================================
echo   删除MQTT防火墙规则
echo ========================================
echo.

:: 检查管理员权限
net session >nul 2>&1
if %errorlevel% neq 0 (
    echo [错误] 请以管理员权限运行此脚本
    pause
    exit /b 1
)

echo 准备删除以下防火墙规则：
echo   - MQTT-HTTP (端口 3002)
echo   - MQTT-WebSocket (端口 8081)
echo   - MQTT-MySQL (端口 3307)
echo.

set /p confirm="确认删除? (Y/N): "
if /i not "%confirm%"=="Y" (
    echo 已取消
    pause
    exit /b 0
)

echo.
netsh advfirewall firewall delete rule name="MQTT-HTTP"
netsh advfirewall firewall delete rule name="MQTT-WebSocket"
netsh advfirewall firewall delete rule name="MQTT-MySQL"

echo.
echo 规则已删除
pause
